﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Interfleet.SE.UICompiler.Core
{
    /// <summary>
    /// Builds up the <see cref="CompileResult"/> after a compilation.
    /// </summary>
    public abstract class ResultBuilder
    {
        #region Constructor

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="arguments"><see cref="Arguments"/> for compilation.</param>
        /// <seealso cref="Arguments"/>
        /// <exception cref="ArgumentNullException">If <paramref name="arguments"/> is null</exception>
        internal ResultBuilder(Arguments arguments)
            : this(arguments, new FileProvider())
        {

        }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="arguments"><see cref="Arguments"/> for compilation.</param>
        /// <param name="fileInfoProvider">An instance of <see cref="IFileProvider"/></param>
        /// <exception cref="ArgumentNullException">If <paramref name="arguments"/>
        /// or <paramref name="fileInfoProvider"/> is null</exception>
        public ResultBuilder(Arguments arguments, IFileProvider fileInfoProvider)
        {
            if (arguments == null)
            {
                throw new ArgumentNullException("arguments", "value cannot be null");
            }
            if (fileInfoProvider == null)
            {
                throw new ArgumentNullException("fileInfoProvider", "value cannot be null");
            }
            Arguments = arguments;
            FileInfoProvider = fileInfoProvider;
        }

        #endregion

        /// <summary>
        /// Arguments for compilation
        /// </summary>
        protected Arguments Arguments
        {
            get;
            private set;
        }

        /// <summary>
        /// An instance of <see cref="IFileProvider"/>
        /// </summary>
        protected IFileProvider FileInfoProvider
        {
            get;
            private set;
        }

        /// <summary>
        /// Builds up a result out of the <paramref name="statusMessage"/>
        /// </summary>
        /// <param name="statusMessage">Reply from the compiler</param>
        /// <param name="compilationStartedAt"><see cref="DateTime"/> representing the time when compilation was started</param>
        /// <returns>A <see cref="CompileResult"/></returns>
        public abstract CompileResult Build(string statusMessage, DateTime compilationStartedAt);
    }
}
